QuickOPC User's Guide and Reference
With single-operation synchronous methods, only catch OpcException or UAException
Best Practices > With single-operation synchronous methods, only catch OpcException or UAException

Methods that operate on a single element, e.g. an OPC Data Access or OPC XML-DA item, throw an OpcException exception for all OPC-related errors. In OPC-UA, UAException is used for the same purpose. The only other exceptions that can be thrown are program execution-related errors (such as OutOfMemoryException, or StackOverflowException), and argument validation exceptions, such as ArgumentException.

When you catch OpcException or UAException, you are completely safe that all OPC-related situations that you cannot control will be covered. This includes errors related to arguments that can only be discovered in run-time and depend on the state of environment. For example, an invalid OPC-DA item ID does not throw ArgumentException, but still an OpcException. So, even if something changes in the target OPC server, you can handle it by catching OpcException (or UAException). For more information, see Error Handling.

By catching exceptions other than OpcException (or UAException) in this case, you could improperly hide programming or catastrophic errors that should not be handled in this way.

The SubscribeXXXX and UnsubscribeXXXX methods, such as EasyDAClient.SubscribeItem, EasyDAClient.UnsubscribeItem, or EasyAEClient.SubscribeEvents, work asynchronously. This rule therefore does not apply to them; instead, see Do not catch any exceptions with asynchronous or multiple-operation methods.

See Also